package view;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;

import javax.swing.WindowConstants;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationActionMap;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class SectorBusqueda extends javax.swing.JPanel {
	private JLabel jLabelSectorID;
	private JComboBox jComboBoxSectorID;
	private JButton jButtonSectorCancelar;
	private JButton jButtonSectorID;
	private static SectorBusqueda frameSectorBusquedaInstancia;
	private AbstractAction abstractActionSectorAceptar;
	private SectorModificacion frameSectorModificacion;

	
	public static SectorBusqueda getInstancia() {
		if(frameSectorBusquedaInstancia==null){
			frameSectorBusquedaInstancia=new SectorBusqueda();
		}
		return frameSectorBusquedaInstancia;
	}
	
	
	
	public SectorBusqueda() {
		super();
		
		this.frameSectorModificacion=SectorModificacion.getInstancia();
		this.frameSectorModificacion.setVisible(false);
		
		initGUI();
	}
	
	private void initGUI() {
		try {
			this.setLayout(null);
			{
				jLabelSectorID = new JLabel();
				this.add(jLabelSectorID);
				jLabelSectorID.setText("Seleccione el ID del Sector que desea cambiar:      ");
				jLabelSectorID.setBounds(12, 12, 296, 16);
			}
			{
				ComboBoxModel jComboBoxSectorIDModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });
				jComboBoxSectorID = new JComboBox();
				this.add(jComboBoxSectorID);
				jComboBoxSectorID.setModel(jComboBoxSectorIDModel);
				jComboBoxSectorID.setBounds(95, 34, 189, 23);
			}
			{
				jButtonSectorID = new JButton();
				this.add(jButtonSectorID);
				jButtonSectorID.setText("Aceptar");
				jButtonSectorID.setBounds(79, 91, 90, 24);
				jButtonSectorID.setAction(getAbstractActionSectorAceptar());
			}
			{
				jButtonSectorCancelar = new JButton();
				this.add(jButtonSectorCancelar);
				jButtonSectorCancelar.setText("Cancelar");
				jButtonSectorCancelar.setBounds(169, 91, 99, 23);
				jButtonSectorCancelar.setAction(getAppActionMap().get("actionCancelar"));
			}
			this.setSize(379, 182);
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private AbstractAction getAbstractActionSectorAceptar() {
		if(abstractActionSectorAceptar == null) {
			abstractActionSectorAceptar = new AbstractAction("Aceptar", null) {
				public void actionPerformed(ActionEvent evt) {
					frameSectorModificacion.setVisible(true);
					frameSectorBusquedaInstancia.setVisible(false);
				}
			};
		}
		return abstractActionSectorAceptar;
	}
	
	@Action
	public void actionCancelar() {
		frameSectorBusquedaInstancia.setVisible(false);
	}
	
    /**
    * Returns the action map used by this application.
     * Actions defined using the Action annotation
     * are returned by this method
     */
	private ApplicationActionMap getAppActionMap() {
		return Application.getInstance().getContext().getActionMap(this);
	}

}
